<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">

    <ui:define name="body">

        <h:messages globalOnly="true" styleClass="message"/>

        <h:form id="studentLearningOutcomeForm">

            <rich:panel>
                <f:facet name="header">#{messages['nav.studentlearningoutcome']}</f:facet>
                <rich:simpleTogglePanel label="#{studentLearningOutcomeHome.instance.student != null ? studentLearningOutcomeHome.instance.student.name : messages['slo.details']}"
                                        switchType="ajax"
                                        opened="true">
                    <h:outputText value="#{messages['slo.nostudent']}" id="noStudent" rendered="#{!studentLearningOutcomeHome.wired}"/>
                    <s:decorate id="studentNumberDecoration" template="layout/display.xhtml" rendered="#{studentLearningOutcomeHome.wired}">
                        <ui:define name="label">#{messages['student.number']}</ui:define>
                        #{studentLearningOutcomeHome.instance.student.studentNumber}
                    </s:decorate>
                    <s:decorate id="fnameDecoration" template="layout/display.xhtml" rendered="#{studentLearningOutcomeHome.wired}">
                        <ui:define name="label">#{messages['student.firstname']}</ui:define>
                        #{studentLearningOutcomeHome.instance.student.firstName}
                    </s:decorate>
                    <s:decorate id="lnameDecoration" template="layout/display.xhtml" rendered="#{studentLearningOutcomeHome.wired}">
                        <ui:define name="label">#{messages['student.lastname']}</ui:define>
                        #{studentLearningOutcomeHome.instance.student.lastName}
                    </s:decorate>
                    <s:decorate id="posDecoration" template="layout/display.xhtml" rendered="#{studentLearningOutcomeHome.wired}">
                        <ui:define name="label">#{messages['student.pos']}</ui:define>
                        #{studentLearningOutcomeHome.instance.student.programOfStudy.programCode} - #{studentLearningOutcomeHome.instance.student.programOfStudy.name}
                    </s:decorate>
                    <div style="clear:both"/>
                    <s:button value="#{messages['slo.selectstudent']}"
                              view="/studentList.xhtml">
                        <f:param name="studentListFrom" value="studentLearningOutcomeEdit"/>
                    </s:button>
                    <div style="clear:both"/>
                </rich:simpleTogglePanel>

                <s:decorate id="dateDecoration" template="layout/edit.xhtml">
                    <ui:define name="label">#{messages['date']}</ui:define>
                    <rich:calendar id="date" datePattern="dd.MM.yyyy" value="#{studentLearningOutcomeHome.instance.date}" required="true" />
                </s:decorate>
                <s:decorate id="inCooperationDecoration" template="layout/edit.xhtml">
                    <ui:define name="label">#{messages['slo.company']}</ui:define>
                    <h:selectBooleanCheckbox id="inCooperationWithCompany"
                                             value="#{studentLearningOutcomeHome.instance.inCooperationWithCompany}" />
                </s:decorate>


                <div style="clear:both"/>
                <p></p>
                <h:outputText id="explainTraitAdding" value="#{messages['slo.notraits.explain']}" rendered="#{!studentLearningOutcomeHome.managed}" />
                <rich:simpleTogglePanel label="#{messages['trait.label']}"  rendered="#{studentLearningOutcomeHome.managed}" switchType="ajax" opened="true">
                    <h:outputText value="#{messages['trait.notraits']}" id="noTraits" rendered="#{empty studentLearningOutcomeHome.positions}"/>
                    <rich:dataTable value="#{studentLearningOutcomeHome.positions}" var="_position" rendered="#{not empty studentLearningOutcomeHome.positions}">
                        <rich:column>
                            <f:facet name="header">#{messages['trait.number']}</f:facet>
                            #{_position.trait.number}
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">#{messages['trait.label']}</f:facet>
                            #{_position.trait.name}
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">#{messages['trait.failsexpectations']}</f:facet>
                            #{_position.trait.failsExpectations}
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">#{messages['trait.meetsexpectations']}</f:facet>
                            #{_position.trait.meetsExpectations}
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">#{messages['trait.exceedsexpectations']}</f:facet>
                            #{_position.trait.exceedsExpectations}
                        </rich:column>
                        <rich:column>
                            <f:facet name="header">#{messages['result.label']}</f:facet>
                            <h:selectOneMenu id="result"
                                             value="#{_position.result}"
                                             required="true">
                                <s:selectItems var="_resList" value="#{resultList}"
                                               label="#{_resList.description}"/>
                                <s:convertEntity/>
                            </h:selectOneMenu>
                        </rich:column>
                    </rich:dataTable>
                    <div style="clear:both"/>
                </rich:simpleTogglePanel>
                <p></p>
                <rich:simpleTogglePanel label="#{messages['slo.comment']}" rendered="#{studentLearningOutcomeHome.managed}" switchType="ajax" opened="true">
                    <s:decorate id="commentDecoration" template="layout/edit.xhtml">
                        <ui:define name="label">#{messages['slo.comment']}</ui:define>
                        <h:inputTextarea id="comment" required="false"
                                         value="#{studentLearningOutcomeHome.instance.comment}"
                                         rows="10" cols="50"/>
                    </s:decorate>
                    <div style="clear:both"/>
                </rich:simpleTogglePanel>
            </rich:panel>

            <div class="actionButtons">
                <h:commandButton id="save"
                                 value="#{messages['button.save']}"
                                 action="#{studentLearningOutcomeHome.persist}"
                                 rendered="#{!studentLearningOutcomeHome.managed}"/>
                <h:commandButton id="update"
                                 value="#{messages['button.update']}"
                                 action="#{studentLearningOutcomeHome.update}"
                                 rendered="#{studentLearningOutcomeHome.managed}"/>
                <h:commandButton id="delete"
                                 value="#{messages['button.delete']}"
                                 action="#{studentLearningOutcomeHome.remove}"
                                 immediate="true"
                                 rendered="#{studentLearningOutcomeHome.managed}"/>
                <s:button propagation="end"
                          id="done"
                          value="#{messages['button.done']}"
                          view="/#{empty sloEditFrom ? 'studentLearningOutcomeList': sloEditFrom}.xhtml"/>
            </div>

        </h:form>

    </ui:define>

</ui:composition>